package sonet;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
	
*/
public class SocialNetwork implements Serializable{
	
	/**		
		@return root agent
	*/
	AgentRoot getRoot(){
		return _root;
	}
	
/** Gets All Agents of the SocialNetwork. */	
	public Collection<Agent> getAgents(){
		return _agents.values();
	}
	
/** Gets one specified Agent. */	
	public Agent getAgent(Integer id){
		if(id == 0)return _root; 
		return _agents.get(id);
	}
	
/** Adds one Agent to the Agents Map. */	
	public void addAgent(Agent a){
		_agents.put( a.getIdentifier(), a);		
	}
	
/** Gets one specified Publication. */	
	public Publication getPublication(Integer id){
		return _publications.get(id);	
	}
	
/** Adds one Publication to the Publications Map. */	
	public void addPublication(Publication p){
		_publications.put( p.getIdentifier() , p);
	}
	
/** Gets one specified Message. */	
	public Message getMessage(Integer id){
		return _messages.get(id);
	}
	
/** Adds one Message to the Messages Map. */	
	public void addMessage(Message m){
		_messages.put( m.getIdentifier() , m);
	}	
	
	
	/** Root agent */
	private AgentRoot _root = new AgentRoot();
	
	/** Agents */
	private Map<Integer, Agent> _agents = new HashMap<Integer, Agent>();
	
	/** Publications */
	private Map<Integer, Publication> _publications = new HashMap<Integer, Publication>();
	
	/** Messages  */
	private Map<Integer, Message> _messages = new HashMap<Integer, Message>();
	
}